-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PEP 818: Adding the Core of the Pyodide Foreign Function Interface to Python #4739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c55b8c8 to
7fe9188
Compare
|
I've added the new PEP checklist (from https://github.com/python/peps/blob/main/.github/PULL_REQUEST_TEMPLATE/Add%20a%20new%20PEP.md), please could you check off as necessary? @ambv Please can you confirm sponsorship? |
a6472ef to
82fbc12
Compare
|
Thanks Hugo! |
9c773b1 to
abda220
Compare
|
Let's renumber this to 9999 for now, we also have #4740 clashing. |
Confirmed! |
|
Thanks! @hoodmane Please use PEP 818. |
68edc4b to
ec236c4
Compare
|
Okay updated it to say pep 818 everywhere. |
| ``jskey``. | ||
| b. Set the ith entry of ``pykwnames`` to ``_Py_js2python(jsitem)``. | ||
|
|
||
| 6. Let ``pyresult`` be ``_PyObject_Vectorcall(callable, pyargs, num_pos_args, pykwnames)``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's PyObject_Vectorcall now; the underscored name is a backcompat alias.
| 6. Let ``pyresult`` be ``_PyObject_Vectorcall(callable, pyargs, num_pos_args, pykwnames)``. | |
| 6. Let ``pyresult`` be ``PyObject_Vectorcall(callable, pyargs, num_pos_args, pykwnames)``. |
(I opened a docs PR for CPython to make this clear: python/cpython#143568)
| same thing as a Python reserved word (for example, ``Array.from``, | ||
| ``Promise.then``). We access these from Python using the valid identifiers | ||
| ``from_`` and ``then_``. If we want to access a JavaScript property called | ||
| ``then_`` we access it from ``then__`` and so on. So if the attribute is a | ||
| Python reserved word followed by one or more underscores, we remove one | ||
| underscore from the end. The following helper function is used for this: | ||
|
|
||
| .. code:: python | ||
|
|
||
| def normalize_python_reserved_words(attr): | ||
| stripped = attr.strip("_") | ||
| if not is_python_reserved_word(stripped): | ||
| return attr | ||
| if stripped != attr: | ||
| return attr[:-1] | ||
| return attr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're called keywords, and there's a iskeyword function.
| same thing as a Python reserved word (for example, ``Array.from``, | |
| ``Promise.then``). We access these from Python using the valid identifiers | |
| ``from_`` and ``then_``. If we want to access a JavaScript property called | |
| ``then_`` we access it from ``then__`` and so on. So if the attribute is a | |
| Python reserved word followed by one or more underscores, we remove one | |
| underscore from the end. The following helper function is used for this: | |
| .. code:: python | |
| def normalize_python_reserved_words(attr): | |
| stripped = attr.strip("_") | |
| if not is_python_reserved_word(stripped): | |
| return attr | |
| if stripped != attr: | |
| return attr[:-1] | |
| return attr | |
| same thing as a Python keyword (for example, ``Array.from``, | |
| ``Promise.then``). We access these from Python using the valid identifiers | |
| ``from_`` and ``then_``. If we want to access a JavaScript property called | |
| ``then_`` we access it from ``then__`` and so on. So if the attribute is a | |
| Python keyword followed by one or more underscores, we remove one | |
| underscore from the end. The following helper function is used for this: | |
| .. code:: python | |
| def normalize_python_keywords(attr): | |
| stripped = attr.strip("_") | |
| if not keyword.iskeyword(stripped): | |
| return attr | |
| if stripped != attr: | |
| return attr[:-1] | |
| return attr |
(References to reserved_words below also need updating.)
Basic requirements (all PEP Types)
pep-NNNN.rst), PR title (PEP 123: <Title of PEP>) andPEPheaderAuthororSponsor, and formally confirmed their approvalAuthor,Status(Draft),TypeandCreatedheaders filled out correctlyPEP-Delegate,Topic,RequiresandReplacesheaders completed if appropriate.github/CODEOWNERSfor the PEPStandards Track requirements
Python-Versionset to valid (pre-beta) future Python version, if relevantDiscussions-ToandPost-History📚 Documentation preview 📚: https://pep-previews--4739.org.readthedocs.build/